using System;
using Microsoft.Practices.Unity.Utility;
using UniAspect.Common;

namespace UniAspect.ContainerOverride
{
    public class ContainerOverrideKey : IEquatable<ContainerOverrideKey>
    {
        public readonly string ContainerName;

        public ContainerOverrideKey(string containerName)
        {
            Guard.ArgumentNotNullOrEmpty(containerName, "containerName");

            ContainerName = containerName;
        }

        public bool Equals(ContainerOverrideKey other)
        {
            return Equals(ContainerName, other.ContainerName);
        }

        public override bool Equals(object obj)
        {
            return Equals(ContainerName, obj.Cast<ContainerOverrideKey>().ContainerName);
        }

        public override int GetHashCode()
        {
            return ContainerName.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("Container Override Build Key[{0}]", ContainerName);
        }
    }
}